package com.example.restatr.Atcivity.Movie;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;

import com.example.restatr.Adapter.NewsAdapter;
import com.example.restatr.Atcivity.Movie.Fragment.MovieCinemaFragment;
import com.example.restatr.Atcivity.Movie.Fragment.MovieForeshowFragment;
import com.example.restatr.Atcivity.Movie.Fragment.MovieHotFragment;
import com.example.restatr.R;
import com.example.restatr.Tools;
import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class MovieAt extends AppCompatActivity {
    private Toolbar tb;
    private TextView barTitle;
    private EditText search;
    private TabLayout tab;
    private ViewPager XwAtPager;
    private List<Fragment> fragments=new ArrayList<>();
    private List<String> tabTitle=new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_movie_at);

        tb = findViewById(R.id.toolbar);
        barTitle = findViewById(R.id.bar_Title);
        search = findViewById(R.id.search);
        tab = findViewById(R.id.tab);
        XwAtPager = findViewById(R.id.XwAtPager);
        Tools.SetBarTitle(tb,barTitle,"看电影",search,this,false);
        Collections.addAll(tabTitle,"热映","影院","即将上映");
        Collections.addAll(fragments,new MovieHotFragment(),new MovieCinemaFragment(),new MovieForeshowFragment());
        XwAtPager.setAdapter(new NewsAdapter(getSupportFragmentManager(),fragments,tabTitle));
        XwAtPager.setOffscreenPageLimit(fragments.size());
        tab.setTabMode(TabLayout.MODE_FIXED);
        tab.setupWithViewPager(XwAtPager);
    }
}